﻿using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace OA.Models
{
    public class Department
    {
        [Key]
        public int Id { get; set; }

        /// <summary>
        ///  部门名
        /// </summary>
        [Required]
        [DisplayName("部门名")]
        public string Name { get; set; }

        /// <summary>
        ///  排序
        /// </summary>
        [DisplayName("排序")]
        public string Sort { get; set; }

        /// <summary>
        ///  备注
        /// </summary>
        [DisplayName("备注")]
        public string Remarks { get; set; }

        /// <summary>
        ///  部门员工
        /// </summary>
        [DisplayName("部门员工")]
        [InverseProperty("Department")]
	    public virtual ICollection<Account> Employees { get; set; }

        /// <summary>
        ///  上级部门Id
        /// </summary>
        [DisplayName("上级部门")]
        public int? ParentId { get; set; }
        /// <summary>
        ///  上级部门
        /// </summary>
        [DisplayName("上级部门")]
        [ForeignKey("ParentId")]
        public virtual Department Parent { get; set; }
        /// <summary>
        ///  子部门
        /// </summary>
        [DisplayName("子部门")]
        [InverseProperty("Parent")]
	    public virtual ICollection<Department> Children { get; set; }
    }
}
